package com.arch.dev.client.view;

import com.arch.dev.client.inter.IObservable;
import com.arch.dev.client.inter.IObserver;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;




public class MessagePanel extends HorizontalPanel implements IObserver {
	
	boolean saveAlternateColor = true;
	boolean deleteAlternateColor = true;

	public void setSavedMessage(String message) {
		clear();
		String msg = "";
		if (saveAlternateColor) {
			msg = "<b><font color='green'><blink>" + message
					+ "</blink></font></b>";
			saveAlternateColor = false;
		} else {
			msg = "<b><font color='blue'><blink>" + message
					+ "</blue></font></b>";
			saveAlternateColor = true;
		}
		add(new HTML(msg));

	}

	public void setDeleteMessage(String message) {
		clear();

		String msg = "";
		if (deleteAlternateColor) {
			msg = "<b><font color='red'><blink>" + message
					+ "</blink></font></b>";
			deleteAlternateColor = false;
		} else {
			msg = "<b><font color='black'><blink>" + message
					+ "</blue></font></b>";
			deleteAlternateColor = true;
		}

		add(new HTML(msg));
	}
	
	public MessagePanel(){
		
	}

	private IObservable observable;
	public MessagePanel(IObservable observable){
		this.observable = observable;
		this.observable.addObserver(this);
	}

	public void update(Object message) {
	
		setSavedMessage((String)message);
	}

	

}
